{extend name="base"/}
{block name="main"}
<article class="cl pd-20">
    <style>
        .form_li {
            height: 50px;
            line-height: 50px;
            text-align: center;
            font-size: 14px;
        }
        .form_lis {
            width: 570px;
            height: 50px;
            line-height: 50px;
            text-align: center;
            font-size: 14px;
            margin: 0px auto;
        }
        .form_li .form_input {
            width: 220px;
            height: 26px;
            line-height: 26px;
            padding: 3px 6px;
            background: #fff;
            border: 1px solid #ededed;
        }
        .form_about {
            font-size: 13px;
            color: #949494;
            text-align: center;
            height: 50px;
            line-height: 50px;
        }
    </style>
    <!--<div class="form_about">版权信息</div>-->
    <div class="n_tab_line">
        <a href="{:url('user/user_list')}" class="n_tab_list">版权信息</a>
        <div class="cl"></div>
    </div>
    <div class="form_lis">
        <div class="row cl" style="margin-left: 0px;">
            <div style="float: left;;">网站logo：</div>
            <div style="float: left;">
                <p style="height: 45px;width:45px;float: left;">
                    <img id="favicon" src="favicon.ico?v=1.1" alt="" style="width:45px;height:45px;" id="imglogo_pic" class="thumbnail">
                </p>
            </div>
            <div style="float:left;margin-left:-100px;">
                <div class="upload-btn">
                <span>
                    <input name="file_upload" style="display: none" id="uploadImg" type="file" onchange="imgUpload(this);">
                    <input type="hidden" value="" id="logo_pic"/>
                </span>
                    <input class="btn radius btn-secondary" onclick="on_upload()" type="button" style=" color: #333; background-color: #c7c7c7;border-color: #c7c7c7;margin-left:120px;" value="替换图片">
                </div>
            </div>
        </div>
    </div>
    <br/>
    <div class="form_li">
        站点名称：<input class="form_input" style="width: 500px;" type="text" name="site_name"
                    value="{$list.site_name}"/>
    </div>
    <div class="form_li">
        版权信息：<input class="form_input" style="width: 500px;" type="text" name="content" value="{$list.content}"/>
    </div>
{if $WXAPP_TYPE != 100}
    <div class="form_lis" style="text-align: left;">
        返回系统跳转：
        <input type="radio" name="back" value="0" {if $list.back_type == 0} checked="checked" {/if} style="margin-right: 2px;"/>主系统
        <input type="radio" name="back" value="1" {if $list.back_type == 1} checked="checked" {/if} style="margin-left: 8px;margin-right: 2px;"/>独立页面
    </div>
{/if}
    <div class="form_about" style="width: 570px;margin: 0 auto;text-align: left;">
        <input class="btn btn-primary radius" onclick="comm('{$list.id}');" type="button"
               value="&nbsp;&nbsp;保存&nbsp;&nbsp;">
        <button class="btn btn-primary radius" onclick="clear_temp();" type="button">
            &nbsp;&nbsp;清除站点缓存&nbsp;&nbsp;
        </button>
    </div>
    <div style="height:30px; line-height:30px;"></div>
</article>
<script src="/public/js/ajax_file_upload.js" type="text/javascript"></script>
<script src="/public/js/file_upload_attr.js" type="text/javascript"></script>
<script>
    $(function () {
        $('#favicon').attr('src', 'favicon.ico?v=' + (new Date().getTime() / 1000));
    })
    var lock = false;
    function comm(id) {
        if (!lock) {
            lock = true;
            var back_type = $("input[name='back']:checked").val();
            layer.confirm('确定要保存吗？', function (index) {
                $.ajax({
                    type: "post",
                    url: "__CONF_SITE__admin/league/copyright",
                    data: {
                        id: id,
                        site_name:  $("[name='site_name']").val(),
                        content: $("[name='content']").val(),
                        back_type:back_type,
                    },
                    dataType:'text',
                    success: function (data) {
                        if (data == 1) {
                            layer.msg('保存成功', {icon: 1, time: 1000}, function () {
                                location.reload();
                            });
                        } else {
                            layer.msg('保存失败', {icon: 5, time: 1000});
                            lock = false;
                        }
                    }
                });
            }, function () {
                lock = false;
            })
        }
    }
    function on_upload() {
        $("#uploadImg").click();
    }
    function imgUpload(event) {
        var fileid = $(event).attr("id");
        var str = $(event).next().attr("id");
        var data = {'file_path': ""};
        uploadFile(fileid, data, function (res) {
            if (res.code) {
                $("#img" + str).attr("src", res.data + '?v=' + (new Date().getTime() / 1000));
                layer.msg('替换成功', {icon: 1, time: 1500}, function () {
                    location.reload();
                });
            } else {
                layer.msg('替换失败', {icon: 1, time: 1000});
            }
        });
    }
    //清除整站缓存
    var lonuk = false;
    function clear_temp() {
        if(!lonuk){
            lock = true;
            layer.confirm('确定要清除整个站点下的所有缓存文件吗？', function (index) {
                $.ajax({
                    type: "post",
                    url: "__CONF_SITE__admin/league/clear_temp",
                    data: { },
                    success: function (data) {
                            layer.msg('清除成功', {icon: 1, time: 1000}, function () {
                                //location.reload();
                            });
                    }
                });
            }, function () {
                lock = false;
            })
        }
    }
</script>
{/block}